﻿using System.Collections.ObjectModel;
using Newtonsoft.Json;

namespace EduAssess.Models;

public class Test
{
    [JsonIgnore]
    public Guid Id { get; set; }
    public string Name { get; set; }
    [JsonIgnore]
    public DateTime CreationDate { get; set; }
    public ObservableCollection<Question> Questions { get; set; }
    [JsonIgnore]
    public int QuestionCount => Questions.Count;
    public Test()
    {
        Id = Guid.NewGuid();
        CreationDate = DateTime.Now;
        Questions = new ObservableCollection<Question>();
    }

    public bool IsCorrectTest()
    {
        if (string.IsNullOrWhiteSpace(Name)) return false;

        return QuestionCount != 0 && Questions.All(item => item.IsCorrectQuestion());
    }
}